const mongoose = require("mongoose")

const Schema = mongoose.Schema 

var GoodsOrderSchema = new Schema({
    orderid: {
        type: String,
        required: true
    },
    goods: {
        type: Schema.Types.ObjectId,
        ref: "goods"
    },
    type: {
        type: String,  // 1待付款  2 代发货  3 已发货,待收货  4 完成,待评价  9取消订单
    },
    // 评价列表

    rateList: [
        {
            type: Schema.Types.ObjectId,
            ref: "rates"
        }
    ],
    price: {
        type: String
    },
    isRated: {
        type: String,
        default: "2"    // 1已经评价  2未评价
    }
})


var RateSchema = new Schema({
    orderid: {
        type: String,
        required: true
    },
    content: {
        type: String,
    },
    star: {
        type: String
    },
    //  1充值成功  2充值失败
    status: {
        type: String,
        default: "2"
    },
})

module.exports = {
    GoodsOrder: mongoose.model("goodsOrder", GoodsOrderSchema),
    Rate: mongoose.model("rates", RateSchema),
}